package com.ndkj.rpcserver;

import com.ndkj.rpcserver.common.dto.URL;
import com.ndkj.rpcserver.protocol.HttpServer;
import com.ndkj.rpcserver.register.LocalRegister;
import com.ndkj.rpcserver.register.MapRemoteRegister;

public class BootStrap {

    public static void start(Class interfaceClazz, Class implClazz, String version) {
        // service provider完成本地注册
        LocalRegister.register(interfaceClazz.getName(), version, implClazz);

        // service provider远程注册中心注册
        // ip地址可以使用工具类获取填充，端口号同理
        URL thisProvider = new URL("localhost", 8080);
        MapRemoteRegister.register(interfaceClazz.getName(), version, thisProvider);

        // 启动tomcat
        HttpServer httpServer = new HttpServer();
        httpServer.start("localhost", 8080);
    }

}
